package com.easyOrder.core.json.probe;

import com.easyOrder.core.utils.TypeUtil;

public class SimpleObjectProbe implements ObjectProbe {
	private Object obj;

	private ProbeInfo probeInfo;

	public SimpleObjectProbe(Object obj) {
		this.obj = obj;
		probeInfo = TypeUtil.getCachedProbeInfo(obj.getClass());
	}

	public ProbeInfo getProbeInfo() {
		return probeInfo;
	}

	public Object getValue(String name) {
		Property property = probeInfo.getProperty(name);
		return property.getValue(obj);
	}

	public void setValue(String name, Object value) {
		Property property = probeInfo.getProperty(name, false);
		if (null != property) {
			property.setValue(obj, value);
		}
	}
}
